package ltd.hanamaki.selenium.study.studySelenium;

import org.apache.commons.codec.binary.Base32;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriver.Navigation;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * @author : FHM
 * @data : 2021/9/3 - 10:56
 */
public class Demo01 {



    static WebDriver driver;
    static Navigation navigate;

    @BeforeClass
    public void setUp() {
        /* 3.1.  */
        /* 注册 火狐浏览器打开的位置 */
        System.setProperty("webdriver.gecko.driver", "C:\\Program Files\\Mozilla Firefox\\geckodriver.exe");
        /* 3.2 注册 驱动 */
        driver = new FirefoxDriver();

        /* 实例化 导航对象 */
        navigate = driver.navigate();
    }

    @Test
    public void t() throws InterruptedException {
        /* 打开 百度地址 */
//        driver.get("https://www.baidu.com");

        navigate.to("https://www.baidu.com");
//        URL url = new URL("https://www.baidu.com");
//        navigate.to(url);


        WebElement kw = driver.findElement(By.id("kw"));
        kw.sendKeys("selenium");


        WebElement su = driver.findElement(By.id("su"));
        su.click();

        Thread.sleep(3000);
        navigate.back();
        Thread.sleep(3000);
        navigate.forward();
        Thread.sleep(3000);
        navigate.refresh();

    }



}
